package cn.testfan.util;

import java.util.HashMap;
import java.util.Map;

public class Vars {
	private static Map<Object, Vars> threadMap = new HashMap<>();
	private Map<String, Object> data = new HashMap<>();

	public static Vars getInstance(Object key) {
		Vars vars = threadMap.get(key);
		if (vars == null) {
			vars = new Vars();
			threadMap.put(key, vars);
		}
		return vars;
	}

	public Vars clear() {
		data.clear();
		return this;
	}

	public Object getObject(String key) {
		return data.get(key);
	}

	public void pubObject(String key, Object value) {
		data.put(key, value);
	}

	public String get(String key) {
		return "" + data.get(key);
	}

	public void pub(String key, String value) {
		data.put(key, value);
	}

}
